package chapter3;
import java.util.Scanner;
/****************************************************************
 * Author：icynlau
 * Description:某天是星期几
 * Others： 在泽勒公式中，一月 二月记为上一年的13 14月，
 * 比如用户输入2月  我们要把2转换为14，同时年份-1
 * Date:2021/4/1 
 * ***************************************************************
 */
public class exc3_21 {
	public static void main(String[] args) {
		
		Scanner input=new Scanner(System.in);
		System.out.println("Enter year:");
		int year=input.nextInt();
		System.out.println("Enter month (1-12):");
		int month=input.nextInt();
		System.out.println("Enter the day of the month(1-31):");
		int day=input.nextInt();
		
		int q=day;
		int m=0;
		if(month==1) {
			m=13;
			year-=1;
			
		}else if(month==2) {
			m=14;
			year-=1;
			
		}else {
			m=month;
		}
		int j=Math.abs(year/100);
		int k=year%100;
		
		int h=(q+(26*(m+1)/10)+k+k/4+j/4+5*j)%7;
		
//		String sDay="";
//		
//		switch(h) {
//		case 0:
//			sDay="Saturday";
//			break;
//		case 1:
//			sDay="Sunday";
//			break;
//		case 2:
//			sDay="Monday";
//			break;
//		case 3:
//			sDay="Tuesday";
//			break;
//		case 4:
//			sDay="Wednesday";
//			break;
//		case 5:
//			sDay="Thursday";
//			break;
//		case 6:
//			sDay="Friday";
//			break;
//		
//		}
		//使用数组写更好，数组基础差
		String[]  sDay= {"Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"};
		System.out.println("Day of the week is "+sDay[h]);
		
	}

}
